﻿using System;
using UnityEngine;

namespace RootMotion.FinalIK
{
	// Token: 0x020001C5 RID: 453
	public class OffsetPose : MonoBehaviour
	{
		// Token: 0x0600095F RID: 2399 RVA: 0x00032990 File Offset: 0x00030D90
		public void Apply(IKSolverFullBodyBiped solver, float weight)
		{
			for (int i = 0; i < this.effectorLinks.Length; i++)
			{
				this.effectorLinks[i].Apply(solver, weight, solver.GetRoot().rotation);
			}
		}

		// Token: 0x06000960 RID: 2400 RVA: 0x000329D0 File Offset: 0x00030DD0
		public void Apply(IKSolverFullBodyBiped solver, float weight, Quaternion rotation)
		{
			for (int i = 0; i < this.effectorLinks.Length; i++)
			{
				this.effectorLinks[i].Apply(solver, weight, rotation);
			}
		}

		// Token: 0x04000613 RID: 1555
		public OffsetPose.EffectorLink[] effectorLinks = new OffsetPose.EffectorLink[0];

		// Token: 0x020001C6 RID: 454
		[Serializable]
		public class EffectorLink
		{
			// Token: 0x06000962 RID: 2402 RVA: 0x00032A10 File Offset: 0x00030E10
			public void Apply(IKSolverFullBodyBiped solver, float weight, Quaternion rotation)
			{
				solver.GetEffector(this.effector).positionOffset += rotation * this.offset * weight;
				Vector3 a = solver.GetRoot().position + rotation * this.pin;
				Vector3 vector = a - solver.GetEffector(this.effector).bone.position;
				Vector3 vector2 = this.pinWeight * Mathf.Abs(weight);
				solver.GetEffector(this.effector).positionOffset = new Vector3(Mathf.Lerp(solver.GetEffector(this.effector).positionOffset.x, vector.x, vector2.x), Mathf.Lerp(solver.GetEffector(this.effector).positionOffset.y, vector.y, vector2.y), Mathf.Lerp(solver.GetEffector(this.effector).positionOffset.z, vector.z, vector2.z));
			}

			// Token: 0x04000614 RID: 1556
			public FullBodyBipedEffector effector;

			// Token: 0x04000615 RID: 1557
			public Vector3 offset;

			// Token: 0x04000616 RID: 1558
			public Vector3 pin;

			// Token: 0x04000617 RID: 1559
			public Vector3 pinWeight;
		}
	}
}
